﻿//*******************************************************************************
//* Date         Author              Description
//* 2012-09-02   Tjaart van Wijck    Initial version
//*******************************************************************************

using ExcelDna.Integration;
using NLog;
using NLog.Targets;

namespace Cubicle.Excel.Loggers
{

    [Target("ExcelStatusLogger")]
    public sealed class ExcelStatusLogger : TargetWithLayout
    {

        protected override void Write(LogEventInfo logEvent)
        {
            string message;
            try { message = Layout.Render(logEvent); } catch { message = logEvent.Message; }
            ExcelAsyncUtil.QueueAsMacro(() => XlCall.Excel(XlCall.xlcMessage, true, message));
        }

    }
}
